#ifndef QRESOURCEMANAGER_H
#define QRESOURCEMANAGER_H

#include "../include/resourceinterface.h"

#include <QMap>

struct ResourceInfo;

class QResourceManager : public QResourceInterface
{
public:
    QResourceManager();
    virtual QStringList getTopLevelNames();
    virtual QStringList getResourceNames(const QString &topLevel);
    virtual QStringList getSelectNames();

    virtual void        addSelect(const QString &name);
    virtual void        removeSelect(const QString &name);

    virtual void        addTopLevel(const QString &name);
    virtual void        removeTopLevel(const QString &name);

    virtual void        addResource(const QString &topLevel,const QString &name,const QByteArray &data);
    virtual void        removeResource(const QString &topLevel,const QString &name);

    virtual bool        topLevelCandel(const QString &topLevel);
    virtual bool        resourceCandel(const QString &topLevel, const QString &name);

    void                save(QString toplevel="");
    void                initResource(QString path);

    QByteArray          getResourceData(const QString &topLevel, const QString &name);
protected:
    int                 getInt(QByteArray &array);
    void                writeInt(QByteArray &array,int value);
protected:


    typedef QMap<QString,ResourceInfo> Resource;
    typedef QMap<QString,Resource>     Resources;

    Resources            m_resources;

    QStringList          m_selectList;

    QString              m_path;
};

#endif // QRESOURCEMANAGER_H
